package com.ITD.controller;

import com.ITD.service.UserService;
import com.ITD.utils.JWTUtils;
import com.ITD.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/settings")
public class SettingController {
    @Autowired
    UserService userService;
    @PostMapping("/change_password")
    public Result changePassword(@RequestParam("old_password") String oldPassword, @RequestParam("new_password")String newPassword, @RequestHeader("Authorization")String token){
        String userName = JWTUtils.getUserName(token);
        return userService.changePassword( userName, oldPassword,  newPassword);
    }
}
